home *** CD-ROM | disk | FTP | other *** search
- Path: iway.fr!diagram!usenet
- From: Jean-Dominique BOISSE <jdbo@diagram.fr>
- Newsgroups: comp.lang.c
- Subject: Re: help with strcmp
- Date: Tue, 02 Apr 1996 13:06:19 -0800
- Organization: DIAGRAM
- Message-ID: <316196CB.1125@diagram.fr>
- References: <4jpiek$lp6@blaze.cs.jhu.edu>
- NNTP-Posting-Host: 100.3.13.155
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- John E. Davis wrote:
- > ...
- > void main(int argc, char *argv[])
- > {
- > char buf[20], data[40], *buff, *arg, *fp;
- > FILE *handle, *dest;
- > int n;
- >
- > handle = fopen(argv[1], "r");
- > if(dest = fopen( "dbuild.out", "w")) setup(dest);
- >
- > while(!feof(handle)) {
- > n = 0;
- > fp = fgets(data, 40, handle);
- > if ( strcasecmp(fp, "<action>\n") == 0) /* the coredump is here */
-
- I think that you must use strncasecmp instead of strcasecmp, like this
-
- strncasecmp(fp,"<action>\n",40)
-
- This function will only read 40 characters from fp for the test.
-
- You can also put a '\0' at the very end of fp (fp[40]) and still use
- strcasecmp, but read only 39 chars from handle.
-
-
- Jean-Dominique BOISSE
-
- (jdbo@diagram.fr)
-